package com.estar.integaration;

public class test {



    public static boolean findNums(int[] arr) {
        int totalSum = 0;
        for (int num : arr) {
            totalSum += num;
        }
        int target = totalSum / 3;
        int leftSum = 0, rightSum = 0;
        int left = 0, right = arr.length - 1;
        while (left < right - 1) {
            leftSum += arr[left];
            if (leftSum == target) {
                break;
            }
            left++;
        }
        while (right > left) {
            rightSum += arr[right];
            if (rightSum == target) {
                break;
            }
            right--;
        }
        return left < right && leftSum == target && rightSum == target;
    }

        public static void main(String[] args) {
            int[] arr = {1, 1, 1, 1, 5, 1, 2, 1, 7, 1, 3};
            System.out.println(findNums(arr) ? "Can split" : "Cannot split");
        }
}



